package demo.thread;

import java.util.concurrent.Callable;

/**
 * Created by zhangyanfei on 2018/4/18.
 *
 * @author zhangyanfei
 * @date 2018/04/18
 */
public class CallableTask implements Callable<Integer> {
    private int sum;

    @Override
    public Integer call() throws Exception {
        //异步耗时任务
        System.out.println("耗時任务开始");
        Thread.sleep(2000);
        for (int i = 0; i < 5000; i++) {
            sum += i;
        }
        System.out.println("耗时任务结束");
        return sum;
    }
}
